$themes: (
  light: (
    //字体
    font_color1: #414141,
    font_color2: white,
    //背景
    background_color1: #fff,
    background_color2: #f0f2f5,
    background_color3: red,
    background_color4: #2674e7,
    //边框
    border_color1: #3d414a
  ),
  dark: (
    //字体
    font_color1: #a7a7a7,
    font_color2: white,
    //背景
    background_color1: #1b2531,
    background_color2: #283142,
    background_color3: #1e6ceb,
    background_color4: #323e4e,
    //边框
    border_color1: #3d414a
  )
);


@mixin themeIfy () {
  @each $theme-name, $theme-map in $themes {
    //!global 把局部变量强升为全局变量
    $theme-map: $theme-map !global;
    //判断html的data-theme的属性值  #{}是sass的插值表达式
    //& sass嵌套里的父容器标识   @content是混合器插槽，像vue的slot
    [data-theme="#{$theme-name}"] & {
      @content;
    }
  }
}

//声明一个根据Key获取颜色的function
@function themed($key) {
  @return map-get($theme-map, $key);
}

//获取背景颜色
@mixin background_color($color) {
  @include themeIfy {
    background-color: themed($color)!important;
  }
}

//获取字体颜色
@mixin font_color($color) {
  @include themeIfy {
    color: themed($color)!important;
  }
}

//获取边框颜色
@mixin border_color($color) {
  @include themeIfy {
    border-color: themed($color)!important;
  }
}
